package Consumer;

import java.util.function.Consumer;

/**
 * @Author: ylc
 * @Description:字符串数组当中存有多条信息，请按照格式“姓名：XX。性别：XX。”的格式将信息打印出来。
 * @Date Created in 2022-05-02 15:33
 */
public class Demo3Test {
    public static void printInfo(String[] arr, Consumer<String> con1, Consumer<String> con2){
        for (String message :
                arr) {
            con1.andThen(con2).accept(message);
        }
    }

    public static void main(String[] args) {
        String[] arr = {"叶良承，男", "胡歌，男"};
        printInfo(arr,(message) -> {
            String name = message.split("，")[0];
            System.out.println("姓名：" + name);
        },
        (message) -> {
            String gender = message.split("，")[1];
            System.out.println("性别：" + gender);
        });

    }
}
